<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>系统属性基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/systemStatic/style/admin.css">
    <link rel="stylesheet" href="${ctx}/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/css/public.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
    <style>
        .layui-input-block {
            margin-left: 90px;
        }
        .layui-form-label {
            width: 60px;
            text-align: left;
        }
    </style>
</head>
<body>

<script type="text/html" template>
<form class="layui-form"  requrl="{{ serverPath.systemPath }}/system/sysProperty/get" style="padding: 0px 30px;width: 440px;margin-left: auto;margin-right: auto" lay-filter="sysPropertyDataForm">

    <div style="margin: 15px 0px;height: 471px;overflow: auto;">
        <div class="layui-form-item" style="display: none">
            <label class="layui-form-label">主键</label>
            <div class="layui-input-block">
                <input type="text" name="id"  placeholder="请输入主键"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="id">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">名字<label style="color: red;">*</label></label>
            <div class="layui-input-block">
                <input type="text" name="propertyName"  placeholder="请输入名字"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="propertyName" lay-verify="required|names">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">别名<label style="color: red;">*</label></label>
            <div class="layui-input-block">
                <input type="text" name="propertyAlias"  placeholder="请输入别名"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="propertyAlias" lay-verify="required|alias">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分组<label style="color: red;">*</label></label>
            <div class="layui-input-block">
                <input type="text" name="propertyGroup"  placeholder="请输入分组"
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="propertyGroup" lay-verify="required">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">值</label>
            <div class="layui-input-block">
                <input type="text" name="propertyValue"  placeholder="请输入值"
                       autocomplete="off" class="layui-input " maxlength="500" fieldname="propertyValue">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sn"  placeholder="请输入排序" readonly
                       autocomplete="off" class="layui-input " maxlength="50" fieldname="sn" lay-verify="required|number">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea type="text" name="memo"  placeholder="请输入备注"
                          autocomplete="off" class="layui-textarea " maxlength="500" fieldname="memo">
                </textarea>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div style="text-align: center;">
                <a lay-submit lay-filter="sysProperty" class="layui-btn btn-n" requrl="{{serverPath.systemPath}}/system/sysProperty/save">提交</a>
                <a id="closeWindow" style="margin-left: 10px;" class="layui-btn btn-n layui-btn-danger">取消</a>
        </div>
    </div>
</form>
</script>
<script src="${ctx}/public/component.js" type="text/javascript"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>

    layui.config({
        base: serverPath.systemPath + staticPath.systemPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index','common','laydate','jquery','commons'], function () {
        var $ = layui.jquery;
        var common = layui.common;

        //关闭当前页面
        $("#closeWindow").click(function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        });

        var id = "${id}";
        if(id){
            $("input[name='propertyName']").attr("readonly","readonly");
            $("input[name='propertyAlias']").attr("readonly","readonly");
            $("input[name='propertyGroup']").attr("readonly","readonly");
        }
        var sn = "${sn}";
        $("input[name='sn']").val(sn);

        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name:'sysPropertyDataForm',
            idValue:"${id}",
            primary:"id",
            updateCallback:function (data) {
                if (common.filterRecord(data)) {
                    window.parent.layer.alert(data.msg, function (index) {
                        parent.layer.close(index);
                        parent.layui.totalFilter.init('sysPropertyTable');
                        parent.layui.table.reload('sysPropertyTable');
                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                    });
                } else {
                    window.parent.layer.alert(data.msg);
                }
                return false;
            }
        });

        //自动生成别名
        $("input[name='propertyName']").blur(function () {
            var aliasExist = $("input[name='propertyAlias']").val();
            if(aliasExist || $.trim(aliasExist).length>0){
                return;
            }
            var str = $(this).val();
            if (str === "") return;
            var arrRslt = component.chineseToPinyinAlias(str);
            $("input[name='propertyAlias']").val(arrRslt[0]);
        });
    });
</script>
</body>
</html>